import java.util.concurrent.atomic.AtomicInteger;

public class Test {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger = new AtomicInteger(0);
        Thread t1 = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 5000; i++) {
                    atomicInteger.getAndIncrement();
                }
            }
        };
        t1.start();
        Thread t2 = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 5000; i++) {
                    atomicInteger.getAndIncrement();
                }
            }
        };
        t2.start();
        t1.join();
        t2.join();
        System.out.println(atomicInteger);
    }
}
